<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="renderer" content="webkit" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>{{DB::table('setting')->where('id', '1')->value('name_site')}}</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/admin/reg/font_24081_qs69ykjbea.css">
    <link rel="stylesheet" href="/admin/lib/layui-v2.4.5/layui/css/layui.css">
    <link rel="stylesheet" href="/admin/reg/global.css" charset="utf-8"> {{--
    <link id="layuicss-layer" rel="stylesheet" href="/admin/reg/layer.css" media="all"> --}}
    <style>
        .captcha {
            position: relative;
            height: 38px;
            cursor: pointer;
        }

        input.error,
        select.error,
        textarea.error {
            background-color: #fbe2e2;
            border-color: #c66161;
            color: #c00;
        }

        #sex-error,
        label.error {
            position: absolute;
            right: 10px;
            top: 10px;
            color: #ef392b;
            font-size: 12px;
        }

        #sex-error {
            right: auto;
            /* width:150px;  */
            left: 45px;
            top: 30px;
            font-size: 14px;

            /* line-height: 1px; */
            /* font-size: 
             */
            /* margin-left: 50px; */
        }
    </style>
</head>

<body>
    <div class="fly-header layui-bg-black">
        <div class="layui-container"> 
            {{-- <a class="fly-logo" href="#"> 
                <img src="/admin/reg/HB.ico" alt="layui">
            </a> --}}
            <span style="line-height: 61px;font-size:16px;/* margin-left: 55px; */">{{$name_rep}}</span>
            {{-- <ul class="layui-nav fly-nav-user">
                <li class="layui-nav-item"> <a class="iconfont icon-touxiang layui-hide-xs" href="/{{config('constant.name_admin')}}/public/reg"></a> </li>
                <li class="layui-nav-item"> <a href="/{{config('constant.name_admin')}}/public/reg">注册</a> </li>
            </ul> --}}
        </div>
    </div>
    <div class="layui-container fly-marginTop">
        <div class="fly-panel fly-panel-user" pad20="">
            <div class="layui-tab layui-tab-brief" lay-filter="user">
                <ul class="layui-tab-title">
                    <li class="layui-this">账号密码登录</li>
                    @if (config('constant.is_profession_ver') && config('constant.wechat_have'))
                    <li><a href="/{{config('constant.name_admin')}}/loginByWeChat">微信扫码登录</a></li>
                    @endif
                </ul>
                <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
                    <div class="layui-tab-item layui-show">
                        <div class="layui-form layui-form-pane">
                            <form autocomplete="off" id="form-login">
                                <div class="layui-form-item"> <label for="username" class="layui-form-label">登录名</label>
                                    <div class="layui-input-inline"> <input type="text" id="username" name="username" class="layui-input" autofocus autocomplete="off">
                                    </div>
                                    <!-- <div class="layui-form-mid layui-word-aux">你在社区的名字</div> -->
                                </div>
                                <div class="layui-form-item"> <label for="password" class="layui-form-label">密码</label>
                                    <div class="layui-input-inline"> <input type="password" id="password" name="password" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item"> <label for="captcha" class="layui-form-label">验证码</label>
                                    <div class="layui-input-inline"> <input type="text" id="captcha" name="captcha" class="layui-input" maxlength="4">
                                    </div>
                                    <div class="layui-form-mid" style="padding: 0!important;"> <img src="{{ captcha_src('flat') }}" class="captcha"> </div>
                                </div>

                                @csrf

                                <div class="layui-form-item">
                                    <input class="layui-btn" type="submit" value=" 登　录 " id="submit_login" style="margin-left:120px">
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="fly-footer">
        @if (config('constant.is_huibang'))
            <p>本系统由<a href="http://www.hbdq.net/" target="_blank">保定市汇邦电气有限公司</a>提供技术支持</p>
        @endif
        <p>备案号：<a href="http://www.beian.miit.gov.cn" target="_blank">冀ICP备05003073号</a></p>
    </div>
    <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
    <script src="/admin/lib/layui-v2.4.5/layui/layui.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/jquery.form.js"></script>
    <script>
        $(function() {

            layui.use(['layer', 'form'], function() {
                var layer = layui.layer,
                    form = layui.form;
                /*********此处为全局变量定义区域-----开始***********/
                //layer弹窗的索引，关闭layer时要用到
                var index2;
                //获取验证码的地址  
                var src = $('.captcha').attr('src');

                /*********此处为全局变量定义区域-----结束***********/
                //点击切换验证码
                $('.captcha').click(function() {
                    $(this).attr('src', src + '=' + Math.random());
                });

                //以JavaScript弹窗形式输出错误的内容
                @if($errors -> any())
                var allError = '';
                @foreach($errors -> all() as $error)
                allError += "{{$error}}<br/>";
                @endforeach
                //输出错误信息 
                layer.open({
                    content: allError,
                    title: false,
                    type: 0,
                    icon: 5,
                    // skin: 'layui-layer-molv',
                    btn: '',
                    closeBtn: 2, //右上角关闭按钮风格  0无,1默认,2
                    shadeClose: true, //开启遮罩关闭
                    time: 0,
                    anim: 6, //弹出动画
                });
                @endif

                $("#form-login").validate({
                    rules: {
                        username: {
                            required: true,
                            notSpace: true,
                        },
                        password: {
                            required: true,
                        },
                        captcha: {
                            required: true,
                            minlength: 4,
                            // maxlength:4,//直接写在input内，可以限制只能输入4个字符
                            isCaptcha: true,
                        },
                    },
                    // onkeyup:false,  //建议关闭
                    // focusCleanup:false,//建议关闭
                    success: "valid",
                    submitHandler: function(form) {
                        $(form).ajaxSubmit({
                            type: 'post',
                            url: "/{{config('constant.name_admin')}}/public/check", //自己提交给自己可以不写url   
                            //beforeSend  beforeSubmit
                            beforeSend: function() {
                                //0.4透明度 白色遮罩
                                index2 = layer.load(2, {
                                    shade: [0.3, '#fff']
                                });
                                $('#submit_login').val('登录中 ···');
                                $('#submit_login').addClass('layui-btn-disabled');
                            },
                            complete: function() {
                                layer.close(index2);
                            },
                            success: function(data) {
                                //判断登录结果 
                                if (data === 'true') {
                                    window.location.href = "/{{config('constant.name_admin')}}/index/index";
                                } else {
                                    // 更新验证码
                                    $('.captcha').attr('src', src + '=' + Math.random());
                                    $('#submit_login').val(' 登　录 ');
                                    $('#submit_login').removeClass('layui-btn-disabled');
                                    layer.open({
                                        content: data,
                                        title: false,
                                        type: 0,
                                        icon: 5,
                                        // skin: 'layui-layer-molv',
                                        btn: '',
                                        closeBtn: 2, //右上角关闭按钮风格  0无,1默认,2
                                        shadeClose: true, //开启遮罩关闭
                                        time: 0,
                                        anim: 6, //弹出动画
                                    });
                                }
                            },
                            error: function(data) {
                                // 更新验证码
                                $('.captcha').attr('src', src + '=' + Math.random());
                                $('#submit_login').val(' 登　录 ');
                                $('#submit_login').removeClass('layui-btn-disabled');

                                if (data.status == 422) {
                                    // var json=JSON.parse(data.responseText);
                                    var json = $.parseJSON(data.responseText);
                                    allError = '';
                                    $.each(json.errors, function(index, el) {
                                        allError += el + '<br>';
                                    });
                                    //输出错误信息 
                                    layer.open({
                                        content: allError,
                                        title: false,
                                        type: 0,
                                        icon: 5,
                                        // skin: 'layui-layer-molv',
                                        btn: '',
                                        closeBtn: 2, //右上角关闭按钮风格  0无,1默认,2
                                        shadeClose: true, //开启遮罩关闭
                                        time: 0,
                                        anim: 6, //弹出动画
                                    });
                                } else {
                                    console.log(data);
                                    layer.msg('出错了!<br>' + data.status + '(' + data.statusText + ')', {
                                        icon: 2,
                                        time: 5000
                                    });
                                }
                            } ///error---end
                        }); //ajaxSubmit---end
                    } //submitHandler---end
                }); //validate---end
            }); //layui.use---end
        }); //$(function()---end
    </script>
</body>

</html>